<?php
//装饰器模式做文章修饰功能
class BaseArt {
	protected $content;
	protected $art = null;
	public function __construct($content) { 
		$this->content = $content ;
	}
	public function decorator() {
		return $this->content;
	}
}
/*	
class BianArt extends BaseArt{
	public function decorator(){
	 return	parent::decorator()."小编加了摘要";
	}
}
	
class SEOArt extends BaseArt{
	public function decorator(){
	 return	parent::decorator()."SEO加了";
	}
}
//现在这两个是平级的没有了继承 也不知道先后顺序 怎么办？
	
$BA = new BaseArt('天天向上');
 $BA->decorator();
	
$art = new BianArt('art');
echo $art->decorator()	
*/

class BianArt extends BaseArt{
	public function __construct(BaseArt $art){
		//普通文章传过来 自己调用自己给加上内容
		$this->art=$art;
		$this->decorator();
	}
	public function decorator(){
	 //return parent::decorator()."小编加了摘要";
	return $this->content= $this->art->decorator()."小编加了摘要";
	}
}
class SeoArt extends BaseArt{
	public function __construct(BaseArt $art){
		//普通文章传过来 自己调用自己给加上内容
		$this->art=$art;
		$this->decorator();
	}
	public function decorator(){	 
	return $this->content= $this->art->decorator()."seo优化";
	}
}		
$con = new BianArt(new BaseArt('con'));
echo $con->decorator();	
//呵呵接下来有意思了
// 正常是这么new   $con2 = new SeoArt();
$con2 = new SeoArt(new BianArt(new BaseArt('con')));
echo $con2->decorator();
?>






















